Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
dom-peekaboo
Advanced tools
Functions for tracking a DOM node's intersection with the viewport.
npm install dom-peekaboo
import { peekaboo } from 'dom-peekaboo';
function onChange(isIntersecting) {
console.log(
`Element is ${isIntersecting ? 'visible' : 'not visible'} in the viewport`,
);
}
peekaboo(document.getElementById('test'), onChange);
All functions accept the same set of parameters with the following type:
(
element: HTMLElement,
onChange: (isIntersecting: boolean) => void,
options?: Options,
) => () => void;
The following options are available:
offsetBottom?: number
: Number of pixels to add to the bottom of the area
checked against when computing element intersection. (default: 0
)
offsetLeft?: number
: Number of pixels to add to the left of the area checked
against when computing element intersection. (default: 0
)
offsetRight?: number
: Number of pixels to add to the right of the area
checked against when computing element intersection. (default: 0
)
offsetTop?: number
: Number of pixels to add to the top of the area checked
against when computing element intersection. (default: 0
)
throttle?: number
: Number of ms to throttle scroll events (only applies in
environments that don't support IntersectionObserver or when using
useScrollIntersection
/useScrollIntersectionChangeCallback
). (default:
100
)
io
: Uses an IntersectionObserver to trigger onChange
when element
enters
or exits the viewport.
scroll
: Uses a scroll event listener, getBoundingClientRect
, and
ResizeObserver to trigger onChange
when element
enters or exits the
viewport.
peekaboo
: Uses io
to trigger onChange
in browsers that support
IntersectionObserver and falls back to using scroll
in browsers that don't.
offsetBottom
/offsetLeft
/offsetRight
/offsetTop
to be -1
.rootMargin
in iframe contexts, which means that
offsets will be ignored.
FAQs
Functions for tracking a DOM node's intersection with the viewport.
We found that dom-peekaboo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.